<?php
namespace app\example\controller;

use app\common\controller\Front;

class Form extends Front
{
    public function _initialize()
    {
        parent::_initialize();
    }
    
    public function index()
    {
        $this->assign('forms',[
            'name'     => 'example/form/index',
            'class'    => 'bg-white',
            'action'   => DcUrl('example/form/save'),
            'method'   => 'post',
            'submit'   => lang('submit'),
            'reset'    => lang('reset'),
            'close'    => false,
            'ajax'     => false,
            'disabled' => false,
            'callback' => false,
            'data'     => false,
            'items'    => DcFormItems([
                'hidden' => [
                    'type' => 'hidden',
                    'value' => 'hiddenValue',
                ],
                'html1' => [
                    'type' => 'html',
                    'value' => '<div class="form-row">',
                ],
                'custom' => [
                    'type' => 'custom',
                    'value' => 'daicuo',
                    'option' => [
                        'feifeicms' => 'www.feifeicms.org',
                        'daicuo' => 'www.daicuo.org',
                        'gxcms' => 'www.gxcms.com',
                    ],
                    'class' => 'form-group col-md-3',
                    'class_left' => 'w-100',
                    'class_right' => 'w-100',
                ],
                'select' => [
                    'type' => 'select',
                    'value' => 'daicuo',
                    'option' => [
                        'feifeicms' => 'www.feifeicms.org',
                        'daicuo' => 'www.daicuo.org',
                        'gxcms' => 'www.gxcms.com',
                    ],
                    'multiple' => false,
                    'size' => 1,
                    'class' => 'form-group col-md-3',
                    'class_left' => 'w-100',
                    'class_right' => 'w-100',
                ],
                'number' => [
                    'type' => 'number',
                    'value' => '888888',
                    'multiple' => false,
                    'class' => 'form-group col-md-3',
                    'class_left' => 'w-100',
                    'class_right' => 'w-100',
                ],
                'url' => [
                    'type' => 'url',
                    'value' => $this->request->root(true),
                    'multiple' => false,
                    'class' => 'form-group col-md-3',
                    'class_left' => 'w-100',
                    'class_right' => 'w-100',
                ],
                'email' => [
                    'type' => 'email',
                    'required' => true,
                    'maxlength' => '60',
                    'class' => 'form-group col-md-6',
                    'class_left' => 'w-100',
                    'class_right' => 'w-100',
                ],
                'password' => [
                    'type' => 'password',
                    'required' => true,
                    'maxlength' => '60',
                    'class' => 'form-group col-md-6',
                    'class_left' => 'w-100',
                    'class_right' => 'w-100',
                ],
                'html2' => [
                    'type' => 'html',
                    'value' => '</div>',
                ],
                'text' => [
                    'type' => 'text',
                    'required' => true,
                    'maxlength' => '90',
                    'class' => 'form-group row',
                    'class_left' => 'col-12',
                    'class_right' => 'col-12',
                ],
                'tags' => [
                    'type' => 'tags',
                    'value' => 'tag1,tag2,tag3,tag4,tag5',
                    'option' => ['标签1','标签2','标签3','标签4','标签5'],
                    'maxlength' => 8,
                    'class' => 'form-group row',
                    'class_left' => 'col-12',
                    'class_right' => 'col-12',
                    'class_right_control' => 'w-100',
                    'class_tags' => 'form-text font-weight-bold',
                    'class_tags_list' => 'text-purple mr-2',
                ],
                'datetime' => [
                    'type' => 'datetime',
                    'value' => date('Y/m/d'),
                    'class' => 'form-group row',
                    'class_left' => 'col-12',
                    'class_right' => 'col-12',
                ],
                'image' => [
                    'type' => 'image',
                    'title' => 'image',
                    'required' => true,
                    'class' => 'form-group row',
                    'class_left' => 'col-12',
                    'class_right' => 'col-12',
                    'multiple' => true,
                    'onSuccess' => 'daicuo.form.upSuccess',
                    'onError' => 'daicuo.form.upError',
                    'onComplete' => 'daicuo.form.upComplete',
                ],
                'file' => [
                    'type' => 'file',
                    'required' => true,
                    'class' => 'form-group row',
                    'class_left' => 'col-12',
                    'class_right' => 'col-12',
                    'multiple' => false,
                    'onSuccess' => 'daicuo.form.upSuccess',
                    'onError' => 'daicuo.form.upError',
                    'onComplete' => 'daicuo.form.upComplete',
                ],
                'captcha' => [
                    'type' => 'captcha',
                    'required' => true,
                    'style' => 'max-width:145px',
                    'class' => 'form-group row',
                    'class_left' => 'col-12',
                    'class_right' => 'col-12',
                    'class_right_control' => 'form-control',
                ],
                'switch' => [
                    'type' => 'switch',
                    'value' => 'on',
                    'class' => 'form-group row',
                    'class_left' => 'col-2',
                    'class_right' => 'col-10',
                ],
                'checkbox' => [
                    'type' => 'checkbox',
                    'value' => 'daicuo',
                    'option' => [
                        'feifeicms' => 'www.feifeicms.org',
                        'daicuo' => 'www.daicuo.org',
                        'gxcms' => 'www.gxcms.com',
                    ],
                    'class' => 'form-group row',
                    'class_left' => 'col-2',
                    'class_right' => 'col-10',
                ],
                'checkbox-inline' => [
                    'type' => 'checkbox',
                    'value' => 'gxcms',
                    'option' => [
                        'feifeicms' => 'www.feifeicms.org',
                        'daicuo' => 'www.daicuo.org',
                        'gxcms' => 'www.gxcms.com',
                    ],
                    'class' => 'form-group row',
                    'class_left' => 'col-2',
                    'class_right' => 'col-10',
                    'class_right_check' => 'form-check form-check-inline',
                ],
                'radio' => [
                    'type' => 'radio',
                    'value' => 'daicuo',
                    'option' => [
                        'feifeicms' => 'www.feifeicms.org',
                        'daicuo' => 'www.daicuo.org',
                        'gxcms' => 'www.gxcms.com',
                    ],
                    'class' => 'form-group row',
                    'class_left' => 'col-2',
                    'class_right' => 'col-10',
                ],
                'radio-inline' => [
                    'type' => 'radio',
                    'value' => 'gxcms',
                    'option' => [
                        'feifeicms' => 'www.feifeicms.org',
                        'daicuo' => 'www.daicuo.org',
                        'gxcms' => 'www.gxcms.com',
                    ],
                    'class' => 'form-group row',
                    'class_left' => 'col-2',
                    'class_right' => 'col-10',
                    'class_right_check' => 'form-check form-check-inline',
                ],
                'selectarea' => [
                    'type' => 'select',
                    'value' => 'daicuo',
                    'option' => [
                        'feifeicms' => 'www.feifeicms.org',
                        'daicuo' => 'www.daicuo.org',
                        'gxcms' => 'www.gxcms.com',
                    ],
                    'multiple' => true,
                    'size' => 3,
                    'class' => 'form-group row',
                    'class_left' => 'col-2',
                    'class_right' => 'col-10',
                ],
                'json' => [
                    'type' => 'json',
                    'title' => 'json',
                    'value' => json_encode(['www.daicuo.org','www.feifeicms.org','www.gxcms.com']),
                    'rows' => 5,
                    'class' => 'form-group row',
                    'class_left' => 'col-2',
                    'class_right' => 'col-10',
                ],
                'textarea' => [
                    'type' => 'textarea',
                    'rows' => 3,
                    'class' => 'form-group row',
                    'class_left' => 'col-2',
                    'class_right' => 'col-10',
                ],
                'editor' => [
                    'type' => 'editor',
                    'title' => 'editor',
                    'rows' => 10,
                    'height' => '10rem',
                    'class' => 'form-group row',
                    'class_left' => 'col-2',
                    'class_right' => 'col-10',
                ],
            ]),
        ]);
        
        return $this->fetch();
    }
    
    public function save()
    {
        return $this->success('ok');
    }
}